<%
Private Function getIP() 
	Dim strIPAddr
		If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then 
		strIPAddr = Request.ServerVariables("REMOTE_ADDR") 
	ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then 
		strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) 
	ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then 
		strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1) 
	Else 
		strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
	End If 
	getIP = Trim(Mid(strIPAddr, 1, 30)) 
End Function

Function Read_File(sFile) 
	Dim path,fso,fl,fc
	path=Server.MapPath(sFile)
	Set fso=CreateObject("Scripting.FileSystemObject")
	If fso.FileExists(path) Then
		Set fl=fso.OpenTextFile(path,1)
		If Not fl.AtEndOfStream Then
			fc=fl.ReadAll
		End If
		fl.Close:set fl=Nothing
	End If
	Set fso=Nothing
	Read_File=fc
End Function

Function Write_Log(str)
	IPlog=Read_File("log.txt")
	'ip=getIP()
	timelog=Date()&" "&time()
	Set FSO=Server.CreateObject("Scripting.filesystemObject")
	Set txtFile =FSO.CreateTextFile(Server.mappath("log.txt"),true)
	txtFile.WriteLine(IPlog)
	txtFile.WriteLine(timelog)
	'txtFile.WriteLine(ip)
	txtFile.WriteLine(str)
	txtFile.Close
End Function

'IPlog=Read_File("log.txt")
'ip=getIP()
'timelog=time()
'Set FSO=Server.CreateObject("Scripting.filesystemObject")
'Set txtFile =FSO.CreateTextFile(Server.mappath("log.txt"),true)
'txtFile.WriteLine(IPlog)
'txtFile.WriteLine(timelog)
'txtFile.WriteLine(ip)
'txtFile.Close
%>